/**
 * 工作流程相关接口
 */
import { request, workflowRequest } from '@/utils/request'

/** 获取流程表单配置详情 */
export function getProcessFormConfig(id) {
  return request.get('/wx/process-definition/get', {
    params: { id },
  })
}

/** 提交流程表单 */
export function postProcessForm(formData) {
  return request.post('/wx/bpm/process-instance/create', {
    data: formData,
  })
}

/** 获取当前用户部门层级 */
export function getDeptLevel() {
  return request.get('/system/dept/getDeptLevel')
}

/** 获取我的流程数据 */
export function getMyProcessInstanceList(params) {
  return request.get('/wx/bpm/process-instance/my-page', {
    params,
  })
}

/** 获取流程实例的审批记录 */
export function getProcessInstanceAssignList(processInstanceId) {
  return request.get('/wx/bpm/task/list-by-process-instance-id', {
    params: { processInstanceId },
  })
}

/** 获取流程实例的详情 */
export function getProcessInstanceDetail(id) {
  return request.get('/wx/bpm/process-instance/get', {
    params: { id },
  })
}

/** 流程审批 - 通过 */
export function approveTask(data) {
  return request.put('/wx/bpm/task/approve', { data })
}

/** 流程审批 - 拒绝 */
export function rejectTask(data) {
  return request.put('/wx/bpm/task/reject', { data })
}

/** 查询待办任务 */
export function getTodoTasks(params) {
  return workflowRequest.get('/wflow/process/task/todoList', { params })
}

/** 查询已办任务 */
export function getDoneTasks(params) {
  return workflowRequest.get('/wflow/process/task/idoList', { params })
}
